package Maze;

import java.io.File;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        try {

            Scanner myScanner = new Scanner(

                    new File("D:/Sameer_Shetye/Partition/input12/01.txt"));

            int numRows = myScanner.nextInt();

            int numCols = myScanner.nextInt();

            myScanner.nextLine();

 

            int startX = 0;

            int startY = 0;

 

            // New maze

            char[][] maze = new char[numRows][numCols];

 

            for (int i = 0; i < numRows; i++) {

                String nextLine = myScanner.nextLine();

                for (int j = 0; j < numCols; j++) {

                    char nextChar = nextLine.charAt(j);

                    maze[i][j] = nextChar;

                    System.out.print(nextChar);

                }

                System.out.println();

            }

 

            // Find the starting point

            for (int i = 0; i < numRows; i++) {

                for (int j = 0; j < numCols; j++) {

                    if (maze[i][j] == 'S') {

                        System.out.println("Starting coordinates: " + i + ", " + j);

                        startX = i;

                        startY = j;

                    }

                }

            }

 

            // Solve the maze

            MazeSolver newMaze = new MazeSolver(maze);

            newMaze.findPath(startX, startY);

            newMaze.printMaze(startX, startY);

 

        } catch (Exception ex) {

            System.out.println(ex);

        }

    }

}
